<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\batch\ocean\product;

use app\enum\ConfigEnum;
use app\enum\OceanEnum;
use app\model\OeClueProductModel;
use app\model\OeProductModel;
use app\service\batch\MediaInterface;
use app\service\batch\MediaService;

class ClueProductService extends MediaService implements MediaInterface
{
    /**
     * @var string 账户产品锁
     */
    protected const BATCH_KEY = ConfigEnum::CACHE_CONFIG[OceanEnum::BATCH_CONFIG_LOCK_KEY]['clue_product_del'];

    /**
     * 删除失效产品.
     */
    public static function batchClueProductDel(int $accountId = 0, int $version = 0): bool
    {
        return (new OeClueProductModel())
            ->where('account_id', $accountId)
            ->where('version', '<', $version)
            ->delete() > 0;
    }
}
